package com.banciyuan.bcywebview.biz.main.group.hot.viewholder;


import android.content.Context;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.helper.push.PushDataHelper;
import com.banciyuan.bcywebview.utils.universalimageloader.core.ImageLoader;
import com.banciyuan.bcywebview.utils.universalimageloader.utils.ImageOptions;

import de.greenrobot.daoexample.model.Team;

public class ViewGroupBanner {
    private TextView title;
    private ImageView bestIv;

    public ViewGroupBanner(View convertView) {
        title = (TextView) convertView.findViewById(R.id.group_new_item_title_one);
        bestIv = (ImageView) convertView.findViewById(R.id.img_big);
    }

    public void renderData(final Context context, final Team team) {
        if (!TextUtils.isEmpty(team.getIntro())) {
            title.setText(Html.fromHtml(team.getIntro()));
        }
        if (!TextUtils.isEmpty(team.getCover())) {
            bestIv.setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage(team.getCover(), bestIv, ImageOptions.options);
        } else {
            bestIv.setVisibility(View.GONE);
        }
        ((View) (bestIv.getParent())).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PushDataHelper.processInnerPushData(context, team.getCode());
            }
        });
    }
}
